<?php
/**
 * Created by PhpStorm.
 * User: shx
 * Date: 2016/11/15
 * Time: 16:33
 */

// 主播关注路由


Route::get('/api/anchors/gen-rec', function () {
    $rec = \App\Models\Tag\Tag::where('type', 'anchor')->where('is_rec', 1)->get();

    foreach ($rec as $anchor) {
        if (empty($anchor->pinyin)) {
            $anchor->autoComputePinyin()->save();
        }
    }
    return 'done';
});

Route::group(['domain' => 'www.qiyiguo.tv','middleware'=>'domainAuth'], function () {
    Route::get('/anchors', 'AnchorController@index')->name('anchor.index');
    Route::get('/api/anchors/{anchor}/follow', 'AnchorController@follow')->name('anchor.follow');
    Route::get('/anchors/cate/{cate}', 'AnchorController@cate')->name('anchor.cate');
    Route::get('/anchors/{tag_id}', 'AnchorController@show')->name('anchor.show');
    Route::get('/anchors/{anchor_id}/preview', 'AnchorController@preview')->name('anchor.preview');

    Route::bind('tag_id', function ($tag_id) {
        $tag = \App\Models\Tag\Tag::find($tag_id);
        return $tag ? $tag : $tag_id;
    });
});
Route::group(['domain' => 'm.qiyiguo.tv','middleware'=>'domainAuth2'], function () {
    Route::get('/anchors', 'AnchorController@index')->name('anchor.index');
    Route::get('/api/anchors/{anchor}/follow', 'AnchorController@follow')->name('anchor.follow_m');
    Route::get('/anchors/cate/{cate}', 'AnchorController@cate')->name('anchor.cate_m');
    Route::get('/anchors/{tag_id}', 'AnchorController@show')->name('anchor.show_m');
    Route::get('/anchors/{anchor_id}/preview', 'AnchorController@preview')->name('anchor.preview_m');

    Route::bind('tag_id', function ($tag_id) {
        $tag = \App\Models\Tag\Tag::find($tag_id);
        return $tag ? $tag : $tag_id;
    });
});

Route::get('/mysql-pm', function () {
    return view('errors.mysql-pm');
});

Route::get('/mysql-pm/data', function () {
    return \DB::select('show processlist');
});